<!DOCTYPE html>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta id="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>tank登录页面</title>
    <link href="../static/css/bootstrap.css" th:href="@{/static/css/bootstrap.css}" rel="stylesheet"/>
    <link href="../static/css/font-awesome.css" th:href="@{/static/css/font-awesome.css}" rel="stylesheet"/>
    <link href="../static/css/login.css" th:href="@{/static/css/login.css}" rel="stylesheet"/>
    <link href="../static/css/toastr.min.css" th:href="@{/static/css/toastr.min.css}" rel="stylesheet"/>
</head>
<body>

<!--加载首页部分-->
<div id="loginLoading">
    <div></div>
    <div></div>
    <span></span>
</div>

<!--登录部分-->
<div class="container">
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            <form name="user1"  class="form-horizontal" onsubmit="return false;">
                <span class="heading">TK</span>
                <span class="heading1">欢迎使用后台管理系统 </span>
                <div class="form-group">
                    <input type="text" class="form-control" value="tank" onkeyup="this.value=this.value.replace(/\s+/g,'')" name="account" id="account" placeholder="帐号">
                    <i class="fa fa-user"></i>
                </div>
                <div class="form-group help">
                    <input type="password" class="form-control " value="123456" onkeyup="this.value=this.value.replace(/\s+/g,'')" name="password" id="password" placeholder="密码">
                    <i class="fa fa-lock"></i>
                    <a href="#" class="fa fa-question-circle"></a>
                </div>
                <div class="form-group">
                    <div class="main-checkbox">
                        <input type="checkbox" value="None" id="checkbox1" name="check"/>
                        <label for="checkbox1"></label>
                    </div>
                    <span class="text">记住我</span>
                    <button id="submit" type="submit" class="btn btn-default"  >立刻登录</button>
                </div>
            </form>

        </div>
    </div>



</div>

<!--页脚-->
<div class="footer" style=" width:100%;text-align:center;background:#ddd;position:absolute;bottom:0; line-height:80px;">© 2020 tank_ssm Copyright</div>

<script src="../static/js/jquery.min.js" th:src="@{/static/js/jquery.min.js}"></script>
<script src="../static/js/toastr.min.js" th:src="@{/static/js/toastr.min.js}"></script>
<script src="../static/js/common.js" th:src="@{/static/js/common.js}"></script>

<!--点击登录请求API接口-->
<script th:inline="javascript">
    //点击方法
    $("#submit").on("click", function() {
        const account = $("input[name='account']").val();//获取用户输入帐号的值
        const password = $("input[name='password']").val();//获取用户输入的密码的值
        if ((account == "") || (account == null)) {//判断用户名是否为空，为空就弹出提示框"请输入用户名"，否则正常执行下面的代码。
            toastr.error("请输入用户名！");
            return false;
        } else if ((password == "") || (password == null)) {//判断密码是否为空，为空就弹出提示框"请输入密码"，否则正常执行下面的代码。
            toastr.error("请输入帐号！");
            return false;
        }
        //组装传入服务端数据
        const data = {
            "account": account,
            "password": password
        };
        //调用login方法
        login(data);
    });
    //请求服务端API接口
    function login(data){
        myrequest("login",data,'POST',function(data){
            location.href = 'index';
        }, function(data){
            toastr.error(data.msg);
        })
    }
</script>
</body>
</html>